package com.example.briandang;

import android.support.v7.app.ActionBarActivity;
import android.text.Spannable;
import android.text.SpannableString;
import android.app.ActionBar;
import android.graphics.Typeface;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;

/*
 * Styling the Action Bar
 * 
 * - The action bar doesn't need to look the same.
 * - Android includes a Dark and Light theme
 * - You can apply these to the entire app or to individual activities
 * - Use the android:theme attribute in the manifest for <application> or <activity>
 * - Use styles.xml to specify specific style themes
 * - When using the Support Library, you can use:
 * 		Theme.AppCompat
 * 		Theme.AppCompat.Light
 * 		Theme.AppCompat.DarkActionBar // for a light theme with a dark action bar
 * - To change the action bar background color, make a custom theme 
 * 
 * Customizing the Text Color
 * - To modify the color of text in an action bar, override properties for each text element.
 * 
 * */
public class StyleActionBarActivity extends ActionBarActivity {

	@Override
	protected void onCreate(Bundle savedInstanceState) 
	{
		super.onCreate(savedInstanceState);
		
		// Setting custom font in Action Bar Title
		ActionBar ab = getActionBar();
		ab.setDisplayShowCustomEnabled(true);
		ab.setDisplayShowTitleEnabled(true);
		
		SpannableString s = new SpannableString("Style Action Bar");
		s.setSpan(new TypefaceSpan(this, "lobster.ttf"), 0, s.length(),
		        Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
		ab.setTitle(s);
		
		setContentView(R.layout.activity_style_action_bar);

		// Set font for text view
		TextView txt = (TextView) findViewById(R.id.styleActionBarTextView);
		Typeface font = Typeface.createFromAsset(getAssets(), "fonts/lobster.ttf");
		txt.setTypeface(font);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.style_action_bar, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// Handle action bar item clicks here. The action bar will
		// automatically handle clicks on the Home/Up button, so long
		// as you specify a parent activity in AndroidManifest.xml.
		int id = item.getItemId();
		if (id == R.id.action_settings) {
			return true;
		}
		return super.onOptionsItemSelected(item);
	}
}
